Skip to content

test(formatting): isolate Colors state in disable tests (REGE #34) - #44

Merged
4444J99 merged 1 commit into
mainfrom
limen/rege34-colors-isolation
Nov 17, 2026
Merged

4444J99 merged 1 commit into
mainfrom
limen/rege34-colors-isolation

Conversation

@4444J99

@4444J99 4444J99 commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Refs #34 — executes the implementation plan posted on the issue (verified against main 1ef23911, which is still the current main head).

Defect (reproduced at declared dependencies)

Colors.disable() blanks every uppercase attribute, but the two tests that exercise it saved and restored only RED/RESET:

  • rege/tests/test_formatting.py::TestColors::test_colors_disable
  • rege/tests/test_formatting_coverage.py::TestColorsDisable::test_colors_disable_sets_empty_strings

The other attributes (GREEN, YELLOW, BLUE, BOLD_*, DIM, ...) stayed "" for the rest of the process, so any later test asserting on them failed depending on execution order. This is the census's "shared state surviving an earlier disabling test". The defect is invisible in default collection order (the victims happen to run first), which is why main CI is green.

Fix

Test-local isolation only, per the plan: both tests now snapshot the full Colors class dict before disable() and restore it in a finally block. Colors.disable() semantics and all production code are untouched. No dependency or CI changes.

Evidence — environment

Disposable venv, pip install -e ".[dev]", Python 3.12.3, resolved: click 8.5.1 (>=8.5.0 declared), pytest 9.2.0 (>=9.2.0), pytest-cov 7.1.0. (The census ran click 8.1.8 / pytest 9.0.2, below the declared floor.)

Evidence — isolation matrix (same process, forced orders)

Order Before (main 1ef23911) After (this PR)
test_colors_defined alone pass pass
test_colors_disable -> test_colors_defined FAIL (Colors.GREEN == '') pass
test_colors_disable_sets_empty_strings -> test_colors_defined FAIL (same leak) pass
test_formatting.py + test_formatting_coverage.py + test_bloom_misc_final_coverage.py FAIL (test_no_color_env_triggers_disable precondition Colors.GREEN != "") 132 passed
REPL EOF test, timeout 120 pass (0.57s) pass

Evidence — full suite (no deselects, JUnit recorded)

  • Unprivileged user, writable tree, default order: 2004 passed, 0 failed — identical count before and after the fix (the fix removes the order dependence, not a default-order failure).
  • As root, 7 chmod/permission tests fail identically with or without this change (root bypasses permission bits; the census recorded the same environment-only obstacle). Not a repo defect.

Files changed

  • rege/tests/test_formatting.py — full-state snapshot/restore in test_colors_disable
  • rege/tests/test_formatting_coverage.py — same in test_colors_disable_sets_empty_strings

Draft — merge is Anthony's call.

Summary by Sourcery

Enhancements:

  • Isolate Colors state in disable-related tests by restoring the complete class state after each test, preventing order-dependent leakage between tests.

…ests

Colors.disable() blanks every uppercase attribute, but
test_colors_disable (test_formatting.py) and
test_colors_disable_sets_empty_strings (test_formatting_coverage.py)
saved and restored only RED/RESET. The remaining attributes (GREEN,
YELLOW, BLUE, BOLD_*, DIM, ...) stayed blanked for the rest of the
process, so any later test asserting on them failed depending on
execution order — e.g. TestColors::test_colors_defined after
test_colors_disable, and TestFormattingNoColor::
test_no_color_env_triggers_disable (precondition Colors.GREEN != '')
after test_formatting.py.

Both tests now snapshot the full Colors class dict and restore it in
a finally block. Test-local isolation only; Colors.disable()
semantics and all production code are untouched.

Refs #34.
@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Explain Change →

Note

CodeRabbit ASCII loading animation

Currently processing new changes in this PR. This may take a few minutes, please wait...

Review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cabaa709-832a-4398-b050-7b010c6a5812
Commits

Reviewing files that changed from the base of the PR and between 1ef2391 and d42e5a7.

Files selected for processing: 2

  • rege/tests/test_formatting.py
  • rege/tests/test_formatting_coverage.py

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai

sourcery-ai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Reviewer's Guide

Tests

Update both Colors.disable() tests to snapshot all uppercase class attributes and restore them in a finally block, preventing state leaks into later tests.

  • rege/tests/test_formatting.py L34-50
  • rege/tests/test_formatting_coverage.py L18-36

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@4444J99
4444J99 marked this pull request as ready for review November 17, 2026 21:53
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T21:53:56.266441Z
We couldn’t complete this review. Comment @codex review to try again.
d42e5a7 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@4444J99
4444J99 merged commit ce6bf9a into main Nov 17, 2026
9 checks passed
@4444J99
4444J99 deleted the limen/rege34-colors-isolation branch November 17, 2026 21:54
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant